$(function(){
    $.ajax({
        url:url+'admin/role',
        type:"GET",
        success:function(data){
            console.log(data);
            var html ='';
            for (var i=0;i<=data.data.length-1;i++){
                html +=
                    "<tr class=\"table-content\">\n" +
                    "<td style=\"width: 5%\">"+data.data[i].role_id+"</td>" +
                    "<td style=\"width: 15%\">"+data.data[i].desc+"</td>" +
                    "<td style=\"width: 10%\">"+data.data[i].count+"</td>" +
                    "<td style=\"width: 20%\">"+
                    "<!--<a class=\"layui-btn layui-btn-mini\" lay-event=\"detail\">查看</a>-->\n" +
                    "<a class=\"update layui-btn layui-btn-mini layui-btn-normal\" ids='"+data.data[i].role_id+"'>编辑</a>" +
                    "<a class=\"del    layui-btn layui-btn-mini layui-btn-danger\" ids='"+data.data[i].role_id+"'>删除</a>" +
                    "</td>\n" +
                    "</tr>"
            }
            $('#data-table').html(html);
            //todo 编辑
            $('.update').click(function(){
                var id = $(this).attr('ids')
                var urls = "../role/edit.html?id="+id;
                layOpen('修改管理信息','90%','600px',urls)
            });

            //todo 删除
            $('.del').click(function(){
                var id = $(this).attr('ids');
                var data = {'role_id':id};
                var urls = url+'admin/roleDel';
                layFirm('删除',urls,data);
            });
        }
    })
});


$('#btn-add').click(function(){
    var urls = "../role/create.html";
    layOpen('添加管理员','90%','600px',urls)
});






